#include "main.h"
#include "Global.h"

CText::CText(LPDIRECT3DDEVICE9 _device, LPCSTR _font, int _size, bool _bold, bool _italic){
	font=NULL;
	D3DXMatrixIdentity(&trans);
	UINT weight=FW_NORMAL;
	height=_size;
	if(_bold)
		weight=FW_BOLD;

	D3DXCreateFont(_device, height,0, weight, 0, _italic, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT(_font), &font );

}
CText::~CText(){
	font->Release();
}

void CText::Draw(LPCSTR _string, float _x, float _y, D3DCOLOR _color){
	RECT rct={(long)_x,(long)_y,(long)_x+WINDOW_WIDTH,(long)_y+WINDOW_HEIGHT};
	g_pDrawSprite->SetTransform(&trans);
	font->DrawText(g_pDrawSprite, _string, -1, &rct, DT_LEFT, _color );
}

void CText::Draw(LPCSTR _string, float _x, float _y, float _width, float _height, D3DCOLOR _color, DWORD _flags){
	RECT rct={(long)_x,(long)_y,(long)(_x+_width),(long)(_y+_height)};
	g_pDrawSprite->SetTransform(&trans);
	font->DrawText(g_pDrawSprite, _string, -1, &rct, _flags, _color );
}